package com.itzol.controller;


import com.itzol.entity.Category;
import com.itzol.service.CategoryService;
import com.itzol.uitls.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 分类表 前端控制器
 * </p>
 *
 * @author linxin
 * @since 2022-03-09
 */
@RestController
public class CategoryController {

    @Autowired
    private CategoryService categoryService;
    //新增 分类接口
    @PostMapping("/add/category")
    public Result addCategory(@RequestBody Category category){
        return categoryService.addCategory(category);
    }
    //删除分类
    @PostMapping("/delete/category/{id}")
    public Result deleteCategory(@PathVariable("id") Integer id){
        return categoryService.deleteCategory(id);
    }
    //修改分类
    @PostMapping("/editor/category")
    public Result editorCategory(@RequestBody Category category){
        return categoryService.editorCategory(category);
    }
    //获取所有分类
    @PostMapping("/get/category")
    public Result getCategory(){
        return categoryService.getCategory();
    }
}

